﻿/*
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at 
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *  
 */

using System;
using java = biz.ritter.javapi;

namespace biz.ritter.javapi.io
{

    /**
     * A specialized {@link Reader} that reads from a file in the file system.
     * All read requests made by calling methods in this class are directly
     * forwarded to the equivalent function of the underlying operating system.
     * Since this may induce some performance penalty, in particular if many small
     * read requests are made, a FileReader is often wrapped by a
     * BufferedReader.
     * 
     * @see BufferedReader
     * @see FileWriter
     */
    public class FileReader : InputStreamReader
    {

        /**
         * Constructs a new FileReader on the given {@code file}.
         * 
         * @param file
         *            a File to be opened for reading characters from.
         * @throws FileNotFoundException
         *             if {@code file} does not exist.
         */
        public FileReader(File file) ://throws FileNotFoundException {
            base(new FileInputStream(file))
        {
        }

        /*
         * Construct a new FileReader on the given FileDescriptor {@code fd}. Since
         * a previously opened FileDescriptor is passed as an argument, no
         * FileNotFoundException can be thrown.
         * 
         * @param fd
         *            the previously opened file descriptor.
         *
        public FileReader(FileDescriptor fd) :
            base(new FileInputStream(fd)){
        }*/

        /**
         * Construct a new FileReader on the given file named {@code filename}.
         * 
         * @param filename
         *            an absolute or relative path specifying the file to open.
         * @throws FileNotFoundException
         *             if there is no file named {@code filename}.
         */
        public FileReader(String filename) :// throws FileNotFoundException {
            base(new FileInputStream(filename))
        {
        }
    }
}